﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 标签列表Service
    /// </summary>
    public class Normal_TagMapService: IDataService<Normal_TagMapEntity>
    {
        /// <summary>
        /// 新增标签列表
        /// </summary>
        /// <param name="Normal_TagMapEntity"></param>
        /// <returns>string</returns>
        public string Insert(Normal_TagMapEntity normal_tagmapEntity)
        {
            normal_tagmapEntity.DataTable_Action = DataTableAction.Insert;
           Normal_TagMap bll = new Normal_TagMap();
            if (bll.InsertUpdateDelete(normal_tagmapEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回标签列表查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Normal_TagMapEntity> List(QueryParam qp,out int count)
        {
           Normal_TagMap bll = new Normal_TagMap();
            return bll.List(qp, out count);
        }

        /// <summary>
        /// 更新标签列表
        /// </summary>
        /// <param name="Normal_TagMap"></param>
        /// <returns>string</returns>
        public string Update(Normal_TagMapEntity normal_tagmapEntity)
        {
            normal_tagmapEntity.DataTable_Action = DataTableAction.Update;
           Normal_TagMap bll = new Normal_TagMap();
            if (bll.InsertUpdateDelete(normal_tagmapEntity) > 0)
            {
                  return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除标签列表
        /// </summary>
        /// <param name="Normal_TagMap"></param>
        /// <returns>string</returns>
        public string Delete(Normal_TagMapEntity normal_tagmapEntity)
        {
            normal_tagmapEntity.DataTable_Action = DataTableAction.Delete;
            Normal_TagMap bll = new Normal_TagMap();
            if (bll.InsertUpdateDelete(normal_tagmapEntity) > 0)
            {
                  return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删标签列表
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>string</returns>
        public string DeleteList(string idList)
        {
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
           Normal_TagMap bll = new Normal_TagMap();
           if (bll.DelList(strDel) > 0)
            {
                 return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个标签列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Normal_TagMapEntity</returns>
        public Normal_TagMapEntity Look(int id)
        {
           Normal_TagMap bll = new Normal_TagMap();
           return bll.Disp(id);
        }
    }
}
